"""
思路：
1、通过图标或指令启动程序
2、选中输入框
3、输入数据
4、重复2、3操作，直到完成所有的输入内容
5、点击登录

项目名称：自动登录
项目描述：通过windows编程里的识图机制，模拟鼠标键盘实现自动登录
项目环境：vscode && pwin32 && pyautogui
作者：觉性清净
"""
# 导入工具包

import time
import win32api as api
import pyautogui as pgui

import funcs
# qqgame = pgui.locateOnScreen('assets/qq.png')
# pgui.doubleClick(qqgame)
# time.sleep(3)


'''
pip install pywin32 

python venv\Scripts\pywin32_postinstall.py -install
将以下目录中的两个dll,复制到c:\windows\system32下

venv\Lib\site-packages\pywin32_system32
pythoncom38.dll
pywintypes38.dll
'''
def input_code(*args):
    for i in args:
        api.keybd_event(i,0)
def inputnum(*args):
    for i in args:
        api.keybd_event(i+48,0)

qqg = r'D:\TX\QQGameTempest\QQGame.exe'
api.ShellExecute(0,'open',qqg,None,None,1)
time.sleep(1)

user = pgui.locateOnScreen('assets/user.png')
print(user)
pgui.click(user)
funcs.send_key("9999999")


passw = pgui.locateOnScreen('assets/pass.png')
pgui.click(passw)

print(passw)
funcs.send_key(r"password")
time.sleep(1)
# pgui.click(user)
# pgui.moveRel(70,0)

login = pgui.locateOnScreen('assets/login.png')
print(login)
pgui.click(login)


# input_code(48,39,50,51,52)

